import { ref } from 'vue'
import { defineStore } from 'pinia'
import admin from '@/api/admin'

export const useInfoStore = defineStore('info', () => {
  let profile = ref({})

  let loadInfo = async (id) => {
    let { status, msg, data } = await admin.detail({id});
    if(status){
      
      profile.value = data;
      // console.log('data:',profile.value);
    }else{
      ElMessage.error(msg);
    }
   
  }
  let editInfo = async(data) => {
    let { status, msg } = await admin.update({...data});
    if(status){
      profile.value = { ...data };
    }
    
  }
  return { profile, loadInfo, editInfo }
})
